package com.peak.distribution.schedule;

import java.util.Date;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.peak.distribution.service.agent.DisAgentSalesService;
import com.peak.spring.boot.tools.DatePattern;
import com.peak.spring.boot.tools.Dates;

import lombok.extern.slf4j.Slf4j;

@Component
@Slf4j
public class SalesSchedule {
	
	private DisAgentSalesService salesService;

	@Scheduled(cron = "${schedule.sales.statistics.day.log}")
	public void statisticsSalesDayLog() {
		Date now = Dates.now();
		log.info("统计销量任务启动{}", Dates.format(now, DatePattern.SHORT_LINE_TIME));
		salesService.statisticsSalesLog();
		log.info("统计销量任务结束，用时{}秒", (Dates.now().getTime() - now.getTime()) / 1000);

	}
}
